/**
 * @file test_rwqueue.cpp
 * @date 2021/10/28 19:10
 * 
 * @author harrybao (harrybao@123u.com)
 * 
 * @brief 
 * 
 * @version v1.0.0
 * 
 * @copyright Copyright © 2021 harrybao All Rights Reserved
 * 
 * @par history:
 * <table>
 * <tr><th>Date                     <th>Version     <th>Author      <th>Description
 * <tr><td>2021/10/28 19:10         <td>1.0.0       <td>harrybao    <td>创建初始版本
 * </table>
 */


#include "common/readerwriterqueue.h"
#include <cassert>

int main() {
  moodycamel::ReaderWriterQueue<int> q;//rwqueue;

  q.enqueue(17);  // Will allocate memory if the queue is full
  bool succeeded = q.try_enqueue(18);  // Will only succeed if the queue has an
                                       // empty slot (never allocates)
  assert(succeeded);

  int number;
  succeeded = q.try_dequeue(number);  // Returns false if the queue was empty

  assert(succeeded && number == 17);

  // You can also peek at the front item of the queue (consumer only)
  int* front = q.peek();
  assert(*front == 18);
  succeeded = q.try_dequeue(number);
  assert(succeeded && number == 18);
  front = q.peek();
  assert(front == nullptr);  // Returns nullptr if the queue was empty

  return 0;
}